<div class="layui-fluid" id="VIEW-list-tasked" lay-title="我发起的">
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <!--<div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm add">办理</div>
                        <div class="layui-btn layui-btn-sm layui-btn-primary delete-action" data-type="del">删除</div>
                    </div>-->
                    <table id="list-table-tasked" lay-filter="list-table-tasked"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="tong" style="display: none">
    <img src="" id="processShow">
</div>
<script>
    layui.use(['admin', 'table', 'form', 'jquery'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , form = layui.form
            , admin = layui.admin;
        // var view = $('#VIEW-list-tasked');
        var table = layui.table;
        var tableFilter = 'list-table-tasked';
        table.render({
            elem: '[lay-filter="' + tableFilter + '"]',
            url: '/activiti/taskStartPage?token=' + admin.loginToken,
            height: 'full-165',
            cols: [[
                {title: '', type: 'checkbox', fixed: true, width: 60},
                {title: '流程名称', field: 'processName'},
                {title: '申请人', field: 'proposerName'},
                {title: '开始时间', field: 'time', align: 'center', templet: function (d) {
                    var startTime = layui.util.toDateString(d.startTime, 'yyyy-MM-dd')
                    return '<p><span title="' + startTime + '" class="nepadmin-c-gray">' + startTime + '</span></p>';
                    }
                },
                {title: '操作', width: 220, align: 'center', templet: function (d) {
                        var editBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">查看</a>';
                        var showBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="show">流程</a>';
                        return editBtn + showBtn;
                    }
                }
            ]]
        });

        table.on('tool(' + tableFilter + ')', function (obj) {
            if (obj.event === "edit") {
                var url = '';
                if (obj.data.processId.indexOf("leaveProcess") != -1){
                    url = '/oa/leave/leaveCompleteEdit';
                } else if (obj.data.processId.indexOf("reimburseProcess") != -1){
                    url = '/oa/reimburse/reimburseCompleteEdit';
                }
                admin.popup({
                    url: url,
                    area: ['650px', '570px'],
                    data : {
                        table:table,
                        taskId : obj.data.taskId,
                        businessKey : obj.data.businessKey,
                        processId:obj.data.processId,
                        processInstanceId:obj.data.processInstanceId
                    }
                });
                return false
            } else if (obj.event === "show") {
                var index = layer.load(1, {
                    shade: [0.1,'#000'] //0.1透明度的背景
                });
                $('#processShow').attr('src','/activiti/image?processInstanceId='+obj.data.processInstanceId+'&token='+admin.loginToken);
                document.getElementById('processShow').onload = function(e){
                    layer.close(index);
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        area: '516px',
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: $('#tong')
                    });
                };
                return false;
            }
        });
    })
</script>